package cn.ultrarisk.scadmin.manager.web.controller.collection;

import cn.ultrarisk.scadmin.manager.biz.solr.dao.SolrCollectionDAO;
import cn.ultrarisk.scadmin.manager.biz.solr.dto.CollectionSchema;
import cn.ultrarisk.scadmin.manager.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * SchemaController
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/6/7
 * @since V1.0
 */
@Controller
@RequestMapping(value = "/collection/{id}/schema")
public class SchemaController extends BaseController {
    @Autowired
    private SolrCollectionDAO solrCollectionDAO;

    @ResponseBody
    @RequestMapping(value = "")
    public ResponseEntity<CollectionSchema> fields(@PathVariable("id") Integer id) {
        CollectionSchema schema = solrCollectionDAO.getSchema(id);
        return getOkResponseEntity(schema);
    }
}
